<?php

	class Admin
	{
		var $admin_id;
		var $admin_username;
		var $admin_password;
		
		
		public function getAdminId()
		{
			return $this->admin_id;
		}
		public function setAdminId($admin_id)
		{	
			$this->admin_id=$admin_id;
		}


		public function getAdminUsername()
		{
			return $this->admin_username;
		}
		public function setAdminUsername($admin_username)
		{
			$this->admin_username=$admin_username;
		}


		public function getAdminPassword()
		{
			return $this->admin_password;
		}
		public function setAdminPassword($admin_password)
		{
			$this->admin_password=$admin_password;
		}


		public function adminLogin($adminusername,$adminpassword)
		{
			$query = mysql_query('SELECT * FROM admin WHERE 
			admin_username = "'.$adminusername.'" AND 
			admin_password = "'.$adminpassword.'" ')or die (mysql_error());

			$count = mysql_num_rows($query);
			if ($count!=0)
			{
				
				 $_SESSION['admin_id'] = session_id;
				 $_SESSION['admin_username'] = $adminusername;
				echo 'good';
			}
				echo "PASS";
		}
		public function adminLogout()
		{

		}


		public function adminAddSubject($subjectid,$subjectname,$subjectteacher,$subjectfaculty)
		{
			mysql_query('INSERT INTO subject (subject_id,subject_name,subject_teacher,subject_faculty) VALUES
			(
				"'.$subjectid.'","'.$subjectname.'","'.$subjectteacher.'","'.$subjectfaculty.'"
			)
			')or die(mysql_error());   
			return true;
		}
		public function adminDeleteSubject()
		{
			mysql_query('DELETE FROM subject WHERE sub_id = "'. $_POST['sub_id'] .'" LIMIT 1')or die (mysql_error()); 
		}
		public function adminEditSubject($sub_id,$subject_id,$subject_name,$subject_teacher,$subject_faculty)
		{
			mysql_query('UPDATE subject SET subject_id = "'. $_POST['subject_id'] .'" , subject_name = "'. $_POST['subject_name'] .'", subject_teacher = "'. $_POST['subject_teacher'] .'", subject_faculty = "'. $_POST['subject_faculty'] .'" WHERE sub_id="'. $_POST['sub_id'] .'" LIMIT 1')or die(mysql_error());
		}
		public function adminAddInformation($inf_title,$inf_date,$inf_subject,$inf_faculty,$inf_detail)
		{
			mysql_query('INSERT INTO main_information (inf_title,inf_date,inf_subject,inf_faculty,inf_detail) VALUES
			(
				"'.$inf_title.'","'.$inf_date.'","'.$inf_subject.'","'.$inf_faculty.'","'.$inf_detail.'"
			)
			')or die(mysql_error());   
			return true;
			
		}
		public function adminDeleteInformation()
		{

		}
		public function adminEditInformation()
		{

		}
		public function adminDeleteStudent()
		{
			mysql_query('DELETE FROM studentmember WHERE student_id = "'. $_POST['student_id'] .'" LIMIT 1')or die (mysql_error()); 
		}
		public function adminDeleteTeacher()
		{
			mysql_query('DELETE FROM teachermember WHERE teacher_id = "'. $_POST['teacher_id'] .'" LIMIT 1')or die (mysql_error()); 
		}
	}
?>